package pl.makimo.fuzzy.sets;

import pl.makimo.fuzzy.norms.Norm;

public class CompoundFuzzySetFactory {
	public static <T> FuzzySet<T> make(FuzzySet<T> set1, FuzzySet<T> set2, Norm type1norm, Norm type2norm) {
		if (set1 instanceof Type2FuzzySet || set2 instanceof Type2FuzzySet) {
			FuzzySet<T> newset1;
			FuzzySet<T> newset2;
			
			if (set1 instanceof DiscreteFuzzySet) {
				newset1 = Type2DiscreteFuzzySet.fromType1((DiscreteFuzzySet)set1);
			} else {
				newset1 = set1;
			}
				
			if (set2 instanceof DiscreteFuzzySet) {
				newset2 = Type2DiscreteFuzzySet.fromType1((DiscreteFuzzySet)set2);
			} else {
				newset2 = set2;
			}
				
			return new Type2CompoundFuzzySet<T>(newset1, newset2, type2norm);
		} else {
			return new CompoundFuzzySet<T>(set1, set2, type1norm);	
		}
	}
}
